1. Field of the Invention
This invention relates to a method for receiving packets on a network, and more particularly, to a manage method of data buffers for network packets.
2. Description of Related Art
On a computer network, data are typically transmitted in type of packet. On the Ethernet, each packet is variably sized from 64 bytes to 1,520 bytes (B) in length and includes data and information, such as identification number and the source and destination addresses of the packet. When transmitted over the network, a packet will be routed through various nodes to its destination.
In packet transmission, the received packet is first stored in a packet buffer before forwarded to its destination. A conventional packet receiving-transmitting method for handling each received packet involves the use of two descriptor lists, one for packet reception and the other for packet forwarding. The descriptor lists are software data stored in the physical memory space during system initialization. Each descriptor is mapped to the address of the packet buffer where the received packet is temporarily stored before being forwarded to its destination.
FIG. 1 is a schematic diagram used to depict the mapping between a descriptor list and a packet buffer in a conventional packet receiving-transmitting method. As shown, the conventional packet receiving-transmitting method utilizes a storage unit 120 containing a plurality of packet buffers 120a, 120b, 120c, . . . etc., for temporary storage of each received packet. When a network driving software receives a packet 100, the computer system allocates one or several descriptors, such as 110a, 110b, 110c, . . . etc., for forming a descriptor list 110 used for receiving the packet 100. Each of the descriptors 110a, 110b, 110c, . . . , 110f, . . . , etc., is respectively linked to one of data buffers 120a, 120b, 120c, . . . , 120f, . . . etc. The sizes of the data buffers 120a, 120b, 120c, . . . are determined by software. For example, a packet 101 is stored in the data buffer 120d pointed by the descriptor 110d, and a packet 102 is stored in the data buffers 120e and 120f respectively pointed by the descriptors 110e and 110f. Each of the descriptors 110a, 110b, 110c, . . . etc. of the descriptor list 110 records an address of the next descriptor such that all the descriptors are linked together in sequence. Each descriptor is used for recording information such as the length and status of the received packet, and initial address and length of the data buffer and an address of the next descriptor.
FIG. 2 is a schematic diagram showing the data structure of each of the descriptors 110a, 110b, 110c in the descriptor list 110 shown in FIG. 1 (here exemplified by the first descriptor 110a). As shown, the descriptor 110a includes four data blocks RDES0, RDES1, RDES2, and RDES3, which record data length and status of the received packet, an initial address of the packet buffer where the associated packet is stored, and the address (pointer) of the next descriptor in the descriptor list 110.
Referring back to FIG. 1, in response to the received packet 100, the received packet 100 is stored in one of the packet buffers, for example the second packet buffer 120b. Conventionally, the storage space of the packet buffer 120b is sized dynamically in accordance with the length of the received packet 100 so that the packet buffer 120b is enough to accommodate the received packet 100. Moreover, the packet buffer 120b is associated with a plurality of descriptors 110a, 110b, 110c of the descriptor list 110. Each of the descriptors 110a, 110b, 110c is applied to register information about the received packet 100 as depicted in FIG. 2, and to store an Early-Receive (ER) interrupt signal, the length of the associated packet 100, and the starting address of the packet buffer where the associated packet 100 is temporarily stored. These information items allow the computer unit to retrieve the corresponding packet 100 from the associated packet buffer in the storage unit 120. After the packet data associated with the first descriptor 110a have been retrieved, the computer unit performs a write-back operation on the first descriptor 110a so as to reset to unused status. After this, the computer unit can gain access to the next descriptor 110b through the pointer of the first descriptor 110a, so that the computer unit can subsequently retrieve the packet data associated with the next descriptor 110b, and so forth for the third descriptor 110c. After the packet data associated with the second descriptor 110b have been retrieved, the computer unit performs a write-back operation on the second descriptor 110b so as to reset to unused status; and similarly, after the packet data associated with the third descriptor 110c have been retrieved, the computer unit performs a write-back operation on the third descriptor 110c so as to reset to unused status. When an OK interrupt signal appears in a certain descriptor, it indicates that this descriptor is the last one; and consequently, the computer unit will retrieve all the remaining packet data from the packet buffer 120b. This completes the forwarding operation for the received packet 100.
The foregoing packet receiving-transmitting method, however, has some draw-backs. First, it involves a lot of interrupt operations for each descriptor in the descriptor list, which would result in an inefficient receiving-transmitting operation. Moreover, since each received packet is variable in size, it would be difficult to allocate a corresponding space for the packet buffer in the storage unit. Still moreover, since each received packet is associated with a plurality of descriptors and each descriptor requires a write-back operation after the associated packet data is retrieved, it would involve a number of write-back operations for all the descriptors in the received packet during the receiving-transmitting operation for each received packet, which would considerably slow down the system performance. For evaluating performance and efficiency for receiving packets, following aspects should be noticed.
Firstly, transmission time required from a link layer controller and a network driving software to data blocks of an application software should be considered.
Secondly, time and efficiency of occupying the system bus for the link layer controller reading the descriptor list, performing a status write back procedure and transmitting data to the data buffers through DMA should be also considered.
In addition, it cannot be interrupted too much during packet receiving procedure.